#ifndef FSM_INCUBATORFSM_H
#define FSM_INCUBATORFSM_H


#include "fsm.h"

//IncubatorFsm_h_global_start
//Put_your_customer_code_here
#include "log.hpp"
#include "rte/rte.hpp"

#define MODE_STANDBY 1U
#define MODE_CUSTOMER 2U
#define MODE_EGG 3U
#define MODE_PARROT 4U
#define MODE_WORKING 5U
//IncubatorFsm_h_global_end

class IncubatorFsm : public FSM {

//IncubatorFsm_h_class_start
//Put_your_customer_code_here
 public:
  IncubatorFsm() : FSM(state_standby), fsm_instance_name("incubator") {}
//IncubatorFsm_h_class_end

public:

void start() override {
    state_standby.name = "state_standby";
    state_standby.entry = [this]{state_standby_entry();};
    state_standby.exit = [this]{state_standby_exit();};
    state_standby.events[key_switch] = [this]{transit(state_customer);};
    
    state_customer.name = "state_customer";
    state_customer.entry = [this]{state_customer_entry();};
    state_customer.exit = [this]{state_customer_exit();};
    state_customer.events[key_switch] = [this]{transit(state_egg);};
    state_customer.events[key_enter] = [this]{transit(state_working);};
    
    state_egg.name = "state_egg";
    state_egg.entry = [this]{state_egg_entry();};
    state_egg.exit = [this]{state_egg_exit();};
    state_egg.events[key_switch] = [this]{transit(state_parrot);};
    state_egg.events[key_enter] = [this]{transit(state_working);};
    
    state_parrot.name = "state_parrot";
    state_parrot.entry = [this]{state_parrot_entry();};
    state_parrot.exit = [this]{state_parrot_exit();};
    state_parrot.events[key_switch] = [this]{transit(state_standby);};
    state_parrot.events[key_enter] = [this]{transit(state_working);};
    
    state_working.name = "state_working";
    state_working.entry = [this]{state_working_entry();};
    state_working.exit = [this]{state_working_exit();};
    state_working.events[key_switch] = [this]{transit(state_standby);};
    

    enter_initial_state();
}


const std::string key_switch = "key_switch";
const std::string key_enter = "key_enter";

private:

//IncubatorFsm_cpp_global_start
//Put_your_customer_code_here
//IncubatorFsm_cpp_global_end


void state_standby_entry() {
    CCLOG(SWEN_INFO, "{} enter state standby");
//Standby_entry_start
//Put_your_customer_code_here
  Rte::instance().incubator_mode = MODE_STANDBY;
  Rte::instance().incubator_mode_name = "standby";
//Standby_entry_end
}

void state_standby_exit() {
    CCLOG(SWEN_INFO, "{} exit  state standby");
//Standby_exit_start
//Put_your_customer_code_here
//Standby_exit_end
}

void state_customer_entry() {
    CCLOG(SWEN_INFO, "{} enter state customer");
//Customer_entry_start
//Put_your_customer_code_here
  Rte::instance().incubator_mode = MODE_CUSTOMER;
  Rte::instance().incubator_mode_name = "customer";
//Customer_entry_end
}

void state_customer_exit() {
    CCLOG(SWEN_INFO, "{} exit  state customer");
//Customer_exit_start
//Put_your_customer_code_here
//Customer_exit_end
}

void state_egg_entry() {
    CCLOG(SWEN_INFO, "{} enter state egg");
//Egg_entry_start
//Put_your_customer_code_here
  Rte::instance().incubator_mode = MODE_EGG;
  Rte::instance().incubator_mode_name = "egg";
//Egg_entry_end
}

void state_egg_exit() {
    CCLOG(SWEN_INFO, "{} exit  state egg");
//Egg_exit_start
//Put_your_customer_code_here
//Egg_exit_end
}

void state_parrot_entry() {
    CCLOG(SWEN_INFO, "{} enter state parrot");
//Parrot_entry_start
//Put_your_customer_code_here
  Rte::instance().incubator_mode = MODE_PARROT;
  Rte::instance().incubator_mode_name = "parrot";
//Parrot_entry_end
}

void state_parrot_exit() {
    CCLOG(SWEN_INFO, "{} exit  state parrot");
//Parrot_exit_start
//Put_your_customer_code_here
//Parrot_exit_end
}

void state_working_entry() {
    CCLOG(SWEN_INFO, "{} enter state working");
//Working_entry_start
//Put_your_customer_code_here
  Rte::instance().incubator_mode = MODE_WORKING;
  Rte::instance().incubator_mode_name = "working";
//Working_entry_end
}

void state_working_exit() {
    CCLOG(SWEN_INFO, "{} exit  state working");
//Working_exit_start
//Put_your_customer_code_here
//Working_exit_end
}



    
    FSM::State state_standby;
    FSM::State state_customer;
    FSM::State state_egg;
    FSM::State state_parrot;
    FSM::State state_working;
    const std::string fsm_instance_name;
};

#endif